//=============================================================================
#include "CNetworkStream.h"

//=============================================================================
CNetworkStream::CNetworkStream() {
}

//-----------------------------------------------------------------------------
void CNetworkStream::SendHeader(int Socket, char Message, Uint32 DataSize) {
    static Uint8 Buffer[CNETWORKPACKET_HEADER_SIZE];

    sprintf((char*)Buffer, "%c%04d", Message, DataSize);

	if(NET2_TCPSend(Socket, (char*)Buffer, CNETWORKPACKET_HEADER_SIZE) < CNETWORKPACKET_HEADER_SIZE) {
	    printf("Unable to send %s\n", SDL_GetError());
	}

	//printf("Send : %s\n", Buffer);
}

//-----------------------------------------------------------------------------
int CNetworkStream::SendString(int Socket, std::string Content) {
	if(NET2_TCPSend(Socket, (char*)Content.c_str(), Content.size()) < Content.size()) {
	    printf("Unable to send %s\n", SDL_GetError());
	}

	return 0;
}

//-----------------------------------------------------------------------------
int CNetworkStream::SendData(int Socket, Uint8* Data, int DataSize) {
	if(NET2_TCPSend(Socket, (char*)Data, DataSize) < DataSize) {
	    printf("Unable to send %s\n", SDL_GetError());
	}

	return 0;
}

//=============================================================================

